<template>
	<view>
		<view style="box-sizing: border-box;padding: 0 20px;">
			<view v-if="type==2">答对：{{info.right_answer_num}}道，答错：{{info.error_answer_num}}道</view>


			<view v-for="(item,index) in list" class="flex a-t" style="border: #ccc solid 1px;border-radius: 8px;padding: 10px;width: 100%;margin-bottom: 20px;">
				<view>
					<view class="c333 f14" style="margin-top: 10px;">
						{{item.title}}
					</view>
					<view style="margin-top: 10px;">
						<label class="radio" v-if="type==0">
							<radio :checked="true"  /><text style="margin-left: 10px;">{{item.option_json[item.right_option].intro}}</text>
						</label>

						<template v-else>
							<label class="radio">
								<radio :checked="true" :color="item.user_answer==item.right_option ? 'green' : 'red'" /><text style="margin-left: 10px;">{{item.option_json[item.user_answer].intro}}</text>
							</label>
							<view>正确答案：{{item.option_json[item.right_option].intro}}</view>
						</template>

					</view>
				</view>
				<!-- <view style="margin-left: auto;">
					<button class="button f12 cfff">当前题目再发一次/</button>
				</view> -->
			</view>
		</view>
		<view
			@click=""
			v-if="num==0"
			class="button f14"
			style="width: 120px; text-align: center; line-height: 40px;position: fixed; z-index: 1;bottom: 50px; left: 50%; margin-left: -60px; "
		>
			再发一次
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			    type:0,
				list:[],
				info: null,
			}
		},
		onLoad(e) {
		    if(e.type){
		        this.type = e.type;
			}

			switch (e.type) {
				case '0':
                    this.question(e.id)
                    break;
                case '1':
                    this.list=this.vuex_cen.answer
                    break;
                case '2':
                    this.answerRecord(e.id)
                    break;
            }

			uni.setNavigationBarColor({
				frontColor: '#000000',
				backgroundColor: '#ffffff'
			});
		},
		methods: {
			async question(id){
				let data = {
					my_subject_id:id
				}
				let res = await this.$u.apis.question(data)
				this.list=res.questions
			},

            answerRecord(id){
			    let self = this;

                this.$u.apis.friend_answer_record({
					'id': id
				}).then(function (res) {
                    self.info = res[0];
                    self.list = res[0].answer;
                });
			},
		}
	}
</script>

<style>
page{
	background: #fff;
}
</style>
